from django.core.management.base import BaseCommand
from note.models import Category

class Command(BaseCommand):
    help = 'Initialize categories'

    def handle(self, *args, **kwargs):
        categories = [
            "学习笔记",
            "工作记录",
            "生活随记",
            "旅行日志",
            "读书笔记",
            "技术分享",
            "个人反思",
            "日常记录",
            "转载笔记",
        ]

        for category_name in categories:
            category, created = Category.objects.get_or_create(name=category_name)
            if created:
                self.stdout.write(self.style.SUCCESS(f"创建分类: {category_name}"))
            else:
                self.stdout.write(self.style.WARNING(f"分类已存在: {category_name}"))
